<?php
/**
 * Created by PhpStorm.
 * User: JackWang
 * Date: 2022/4/28
 * Time: 13:48
 */

declare(strict_types=1);

use PHPUnit\Framework\TestCase;

final class ErrorSuppressionTest extends TestCase
{
    public function testFileWriting(): void
    {
        $writer = new FileWriter();
        //加上@字符可以抑制报错，不会报错，测试程序会继续运行
        $this->assertFalse(@$writer->write('/is-not-writeable/file', 'stuff'));
        $this->assertFalse(@$writer->write('phpuint/data.csv', 'stuff'));
    }
}

final class FileWriter
{
    public function write($file, $content)
    {
        $file = fopen($file, 'w');
        if ($file == false) {
            return false;
        }
    }
}